package com.cy.pj.common.arithmetic.controller;

import com.cy.pj.common.pojo.ResponseResult;
import com.sun.istack.internal.NotNull;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.Min;

@RestController
@Validated
public class ArithmeticController {

    @RequestMapping("/doCompute/{n1}/{n2}")
    public ResponseResult doCompute(@PathVariable Integer n1,
                                    //@Pattern(regexp="^[1-9]*$",message = "必须是1到9之间的数字")
                                    @Min(value = 1,message = "除数不能为0")
                                    @PathVariable  Integer n2){
        Integer result=n1/n2;
        return  new ResponseResult("result is "+result);
    }
}
